//
//  TTWaterflowerView.h
//  瀑布流练习
//
//  Created by 田涛 on 2017/3/13.
//  Copyright © 2017年 Lemon. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef enum {
    TTWaterflowerViewMarginTypeTop,
    TTWaterflowerViewMarginTypeLeft,
    TTWaterflowerViewMarginTypeBottom,
    TTWaterflowerViewMarginTypeRight,
    TTWaterflowerViewMarginTypeColumn,
    TTWaterflowerViewMarginTypeRow,
} TTWaterflowerViewMarginType;

@class TTWaterflowerView,TTWaterflowerViewCell;

@protocol TTWaterflowerViewDataSource <NSObject>
@required
/**
 *  返回多少组数据
 */
- (NSUInteger)numberOfCellsInWaterflowerView:(TTWaterflowerView *)waterflowerView;
/**
 *  返回Cell
 */
- (TTWaterflowerViewCell *)waterflowerView:(TTWaterflowerView *)waterflowerView cellAtIndex:(NSUInteger)index;

@optional
/**
 *  返回的列数
 */
- (NSUInteger)numberOfColumnsInWaterflowerView:(TTWaterflowerView *)waterflowerView;
@end

@protocol TTWaterflowerViewDelegate <UIScrollViewDelegate>
@optional
/**
 *  返回对应Index的cell的高度
 */
- (CGFloat)waterflowerView:(TTWaterflowerView *)waterflowerView heightAtIndex:(NSUInteger)index;
/**
 *  返回对应类型的间隔
 */
- (CGFloat)waterflowerView:(TTWaterflowerView *)waterflowerView marginForType:(TTWaterflowerViewMarginType)type;
/**
 *  点击对应cell的Index
 */
- (void)waterflowerView:(TTWaterflowerView *)waterflowerView didSelectedAtIndex:(NSUInteger)index;
@end

@interface TTWaterflowerView : UIScrollView
@property (nonatomic, weak) id<TTWaterflowerViewDataSource> dataSource;
@property (nonatomic, weak) id<TTWaterflowerViewDelegate> delegate;

/**
 *  Cell的宽度
 */
- (CGFloat)cellWidth;
/**
 *  刷新方法
 */
- (void)reloadData;
/**
 *  去缓存池查找可循环利用的Cell
 */
- (id)dequeueReusableCellWithIdentifier:(NSString *)identifier;

@end
